package com.lsa.the6046j.ps1;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.regex.Pattern;

public class Unimodal implements Runnable{
	private static Pattern WHITESPACE_PATTERN = Pattern.compile(
            "\\p{javaWhitespace}+");
	static String lineSep = System.getProperty("line.separator");
	
	static void process(InputStream in, PrintStream out) throws IOException {
		TaskReader reader = new TaskReader(in);
		List<Integer> task;
		while((task = reader.nextTask()) != null) {
			echo(out, Arrays.asList(solve(task)));
		}
	}
	
	static <T> void echo(PrintStream out, Collection<T> c) {
		for (Iterator<T> iter = c.iterator(); iter.hasNext();) {
			T e = (T) iter.next();
			out.print(e);
			if (iter.hasNext()) {
				out.print(' ');
			}
		}
		out.print(lineSep);
	}
	
	static Integer solve(List<Integer> arr) {
    	return solveInnerRec(arr, 0, arr.size() - 1);
    }
	
	static Integer solveInnerIter(List<Integer> arr, int left, int right) {
		while(left < right)
		{
			int mid = (left + right) / 2;
			if (arr.get(mid) < arr.get(mid + 1)) {
				left = mid + 1;
			}
			else if (arr.get(mid) > arr.get(mid + 1)) {
				right = mid;
			}
		}
		
		return arr.get(left);
	}
	
	static Integer solveInnerRec(List<Integer> arr, int left, int right) {
		int mid = (left + right) >> 1;
		if (mid > 0 && mid < arr.size()-1) {
			if (arr.get(mid - 1) < arr.get(mid) && arr.get(mid) < arr.get(mid + 1)) {
				return solveInnerRec(arr, mid + 1, right);
			}
			else if (arr.get(mid - 1) < arr.get(mid) && arr.get(mid) > arr.get(mid + 1)) {
				return arr.get(mid);
			}
			else if (arr.get(mid - 1) > arr.get(mid) && arr.get(mid) > arr.get(mid + 1)) {
				return solveInnerRec(arr, left, mid-1);
			}
				
		}
		return null;
	}
	
	static class TaskReader{
		private BufferedReader reader;

        TaskReader(InputStream stream) {
            this.reader = new BufferedReader(new InputStreamReader(stream));
        }
        
        List<Integer> nextTask() throws IOException {
        	List<Integer> pancakes = null;
        	String line;
        	if((line = reader.readLine())!= null) {
        		pancakes = new ArrayList<>(32);
        		String[] parts = WHITESPACE_PATTERN.split(line);
        		for (String p : parts) {
					pancakes.add(Integer.parseInt(p));
				}
        	}
        	return pancakes;
        }
	}
	
	public static void main(String[] args) {
		new Unimodal().run();
	}

	@Override
	public void run() {
		try {
			process(System.in, System.out);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
